/*=====================================================
Critical Links
Auto Configuration Server

Authors:
	Rui Eduardo Gouveia Gil - r-gil@critical-links.com

Date: 2010
Version 0.1
=======================================================*/
#ifndef __USER_H__
#define __USER_H__

#include <string>
#include <iostream>

#include <rgcpp/tools/ToHex.h>
#include <rgcpp/tools/SHAGenerator.h>

namespace acs
{

enum UserType
{
	ACS_USER_GUEST,
	ACS_USER_NORMAL,
	ACS_USER_ADMIN
};

class User
{
	private:
		int id;
		UserType type;
		time_t updated;
		time_t creation;
		std::string name;
		std::string login;
		std::string password;

	public:
		User();
		~User();

		void setID(const int id);
		int getID() const;

		void setType(const UserType type);
		UserType getType() const;
		std::string getTypeStr() const;

		void setUpdated(time_t updated);
		time_t getUpdated() const;

		void setCreation(time_t creation);
		time_t getCreation() const;

		void setName(const std::string& name);
		std::string getName() const;

		void setLogin(const std::string& login);
		std::string getLogin() const;

		void setPassword(const std::string& password, const bool encrypted=true);
		std::string getPassword() const;

		bool validatePassword(const std::string& password);

	private:
		std::string encryptPassword(const std::string& password);
};

}

#endif
